#include <stdio.h>
#include <stdbool.h>

bool f(int num) {
    if (num <= 1) return false;
    for (int i = 2; i * i <= num; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int N;
    scanf("%d", &N);

    int count = 0;
    for (int i = 2; i <= N; i++) {
        if (f(i)) {
            printf("%5d", i);
            count++;
            if (count % 8 == 0) {
                printf("\n");
            }
        }
    }
    if (count % 8 != 0) {
        printf("\n");
    }

    return 0;
}
